/**
 * 
 */
package net.microlinktech.testing.ui.dialog;

import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

/**
 * @author moxin
 * 
 */
public class MessageDialog {

    private MessageDialog() {

    }

    /**
     * 显示提示信息和成功信息
     * 
     * @param message
     */
    public static void showInformation(Object message) {
        show(null, message, "提示", JOptionPane.INFORMATION_MESSAGE);
    }

    /**
     * 显示警告信息
     * 
     * @param message
     */
    public static void showWarn(Object message) {
        show(null, message, "警告", JOptionPane.WARNING_MESSAGE);
    }

    /**
     * 显示失败信息或错误信息
     * 
     * @param message
     */
    public static void showError(Object message) {
        show(null, message, "提示", JOptionPane.ERROR_MESSAGE);
    }

    /**
     * 自定义显示信息
     * 
     * @param parentComponent
     * @param message
     * @param title
     * @param messageType
     */
    public static void show(Component parentComponent, Object message, String title, int messageType) {
        JOptionPane pane = new JOptionPane(message, messageType);
        JDialog dialog = pane.createDialog(parentComponent, title);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
    }

}
